import Vue from "vue";
import App from "./App.vue";

// 定义全局组件
import TypeNav from "@/components/TypeNav";
import Carousel from "@/components/Carousel";
import Pagination from "@/components/Pagination";
import { Button, MessageBox } from "element-ui";
Vue.component(TypeNav.name, TypeNav);
Vue.component(Carousel.name, Carousel);
Vue.component(Pagination.name, Pagination);
// elementUI第一种注册方式注册全局组件
Vue.component(Button.name, Button);
// elementUI第二种注册方式，挂在原型上
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;

// 引入路由
import router from "@/router";

// 引入仓库
import store from "@/store";

// 引入MockServe.js
import "@/mock/mockServe";

// 引入swpier样式
import "swiper/css/swiper.css";

Vue.config.productionTip = false;

// 统一接口api文件夹里的所有请求函数
import * as API from "@/api";

// 引入插件
import VueLazyload from "vue-lazyload";
import loading from "@/assets/loading.jpg";

// 注册插件
Vue.use(VueLazyload, {
  loading: loading,
});

// 引入表单校验插件
import "@/plugins/validate";

new Vue({
  render: (h) => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this;
    Vue.prototype.$API = API;
  },
  // 注册路由
  router,
  // 注册仓库
  store,
}).$mount("#app");
